home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / DarkForge2000 / snippets_vol3 / snip_fireworks.dba < prev    next >
Encoding:
Text File  |  2000-09-30  |  2.0 KB  |  113 lines

  1. `    -------------------------------------------------------------------------
  2. `    5th of November                               DarkForge Snippet 27/9/2000
  3. `    -------------------------------------------------------------------------
  4. `    A quite nice fireworks effect I think! Blurs the smoke trails away, 
  5. `    multiple colours, different amounts of particles.
  6.  
  7. set display mode 320,240,16
  8.  
  9. sync rate 0
  10. sync on
  11. hide mouse
  12.  
  13. w=180
  14. h=120
  15. xh=h/2
  16. t=750
  17.  
  18. create bitmap 2,w,h
  19.  
  20. dim velocity#(t)
  21. dim acceleration#(t)
  22. dim jump(t)
  23. dim x#(t)
  24. dim speed#(t)
  25. dim y#(t)
  26. dim d(t)
  27. dim ink(t)
  28. dim inkcolour(0)
  29.  
  30. makefire(t,w,h,xh)
  31.  
  32. inkcolour(0)=1
  33. start=timer()
  34.  
  35. do
  36.  
  37.     blur bitmap 2,1
  38.  
  39.     ink rgb(0,0,0),0
  40.     dot 0,0
  41.  
  42.     for a=0 to t
  43.  
  44.         if jump(a)=0
  45.             velocity#(a)=6.0+rnd(5)
  46.             jump(a)=1
  47.         endif
  48.     
  49.         if jump(a)=1
  50.             if velocity#(a)!-8
  51.                 velocity#(a)=velocity#(a)-acceleration#(a)
  52.             endif
  53.             y#(a)=y#(a)-velocity#(a)
  54.         endif
  55.     
  56.         temp_x#=x#(a)
  57.         temp_s#=speed#(a)
  58.  
  59.         if y#(a)>h
  60.             y#(a)=h
  61.         else
  62.             if d(a)=1
  63.                 inc temp_x#,temp_s#
  64.             else
  65.                 dec temp_x#,temp_s#
  66.             endif
  67.             x#(a)=temp_x#
  68.         endif
  69.     
  70.         if inkcolour(0)=1 then ink rgb(ink(a),ink(a),ink(a)),0
  71.         if inkcolour(0)=2 then ink rgb(ink(a),ink(a),90),0
  72.         if inkcolour(0)=3 then ink rgb(ink(a),90,ink(a)),0
  73.         if inkcolour(0)=4 then ink rgb(150,90,ink(a)),0
  74.         if inkcolour(0)=5 then ink rgb(50,200,ink(a)),0
  75.         if inkcolour(0)=6 then ink rgb(150,ink(a),ink(a)/2),0
  76.         if inkcolour(0)=7 then ink rgb(ink(a),50,200),0
  77.         if inkcolour(0)=8 then ink rgb(ink(a)/2,ink(a)/2,ink(a)),0
  78.  
  79.         dot x#(a),y#(a)
  80.  
  81.     next a
  82.  
  83.     copy bitmap 2,0,0,179,119,0,0,0,319,239
  84.  
  85.     sync
  86.  
  87.     if timer()=>start+2500+rnd(1000)
  88.         t=250+rnd(500)
  89.         makefire(t,w,h,xh)
  90.         start=timer()
  91.         inkcolour(0)=rnd(7)+1
  92.     endif
  93.  
  94. loop
  95.  
  96. function makefire(t,w,h,xh)
  97.  
  98.     for a=0 to t
  99.  
  100.         velocity#(a)=0
  101.         acceleration#(a)=0.5
  102.         jump(a)=0
  103.         x#(a)=xh+10+rnd(xh/2)
  104.         speed#(a)=rnd(5)
  105.         y#(a)=(h-20)+rnd(20)
  106.         d(a)=rnd(1)
  107.         ink(a)=200+rnd(55)
  108.  
  109.     next a
  110.  
  111. endfunction
  112.  
  113.